<html>
<head><meta charset="utf-8"><title>parsing to ParamKindOrd · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html">parsing to ParamKindOrd</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="199330304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/parsing%20to%20ParamKindOrd/near/199330304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html#199330304">(Jun 01 2020 at 01:49)</a>:</h4>
<p>How do you parse a string to a <code>ParamKindOrd</code>? E.g.: <code>"lifetime"</code> to <code>ParamKindOrd::Lifetime</code></p>



<a name="199330483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/parsing%20to%20ParamKindOrd/near/199330483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html#199330483">(Jun 01 2020 at 01:54)</a>:</h4>
<p>Specific situation: I'm working on <code>librustc_typeck/astconv.rs</code> and specifically on the <code>generic_arg_mismatch_err</code> function, and I need to sort by <code>ParamKindOrd</code>, but one of the inputs to the function is just a <code>&amp;static str</code></p>



<a name="199402507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/parsing%20to%20ParamKindOrd/near/199402507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html#199402507">(Jun 01 2020 at 18:04)</a>:</h4>
<p>It seems like the solution is just a pattern-match on the string</p>



<a name="199402807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/parsing%20to%20ParamKindOrd/near/199402807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html#199402807">(Jun 01 2020 at 18:07)</a>:</h4>
<p>Depending on the exact circumstances, it might also be possible to change it to pass a <code>ParamKindOrd</code>/<code>GenericArg</code> and convert it to a<br>
string in the method itself</p>



<a name="199406420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/parsing%20to%20ParamKindOrd/near/199406420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/parsing.20to.20ParamKindOrd.html#199406420">(Jun 01 2020 at 18:38)</a>:</h4>
<p>I would prefer that, but it would require a lot of changes</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>